package com.jin.webvideo.entity;

import com.jin.webvideo.base.util.CollectionsUtil;
import com.jin.webvideo.util.base.StringUtil;
import lombok.Data;

import java.util.Arrays;
import java.util.List;

public class User {
    @Data
    public static class Role {
        public static final Role ROLE_UNSAFE = new Role("unsafe");
        public static final Role ROLE_ANONYMOUS = new Role("anonymous");
        private String name;
        public Role(String name) {
            this.name = name;
        }
    }
    private String account;
    private String password;
    private String activekey;
    private String img;
    private List<Role> roles;
    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getActivekey() {
        return activekey;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(String roles) {
        String[] role = StringUtil.split(roles, ",");
        this.roles = CollectionsUtil.convert(Arrays.asList(role), (n) -> new Role(n));
    }

    public void setActivekey(String activekey) {
        this.activekey = activekey;
    }
}
